package com.wt.admin.controller.sys;

import com.aizuda.easy.security.domain.Rep;
import com.aizuda.easy.security.domain.Req;
import com.wt.admin.config.aspect.annotation.LogAno;
import com.wt.admin.domain.entity.sys.SysRoleEntity;
import com.wt.admin.domain.vo.sys.SysRoleListVO;
import com.wt.admin.domain.vo.sys.UserVO;

import com.wt.admin.service.sys.SysRoleService;
import com.wt.admin.util.PageUtil;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import jakarta.annotation.Resource;

@RestController
@RequestMapping("role")
public class SysRoleController {

    @Resource
    private SysRoleService sysRoleService;

    @LogAno(name = "角色列表")
    @PostMapping("find")
    public Rep<SysRoleListVO> find(@RequestBody Req<PageUtil.PageDTO<SysRoleEntity>,UserVO> req){
        return Rep.ok(sysRoleService.find(req.getData()));
    }

    @LogAno(name = "修改或添加角色")
    @PostMapping("edit")
    public Rep<SysRoleEntity> edit(@RequestBody Req<SysRoleEntity,UserVO> req){
        return Rep.ok(sysRoleService.edit(req.getData()));
    }

    @LogAno(name = "删除角色")
    @PostMapping("del")
    public Rep<SysRoleEntity> del(@RequestBody Req<SysRoleEntity,UserVO> req){
        return Rep.ok(sysRoleService.del(req.getData()));
    }
}
